#ifndef plugin_output_H
#define plugin_output_H

#include "../../IPlugin.h"
#include "ui_plugin_output.h" // 包含生成的UI头文件"
#include "outputconfigwidget.h"
QT_BEGIN_NAMESPACE
namespace Ui
{
    class plugin_output;
}
QT_END_NAMESPACE

class plugin_output : public IPlugin
{
    Q_OBJECT
    Q_INTERFACES(IPlugin)
    Q_PLUGIN_METADATA(IID "com.example.IPlugin/1.0" FILE "plugin_output.json")

public:
    QString pluginName() const override { return "plugin_output"; }
    QString version() const override { return "1.0"; }

    QWidget *createUI(QWidget *parent) override
    {
        pluginWidget = new QWidget(parent);
        plugin_output_ui = new Ui::plugin_output(); // 创建UI实例
        plugin_output_ui->setupUi(pluginWidget);    // 设置UI到widget
        return pluginWidget;
    }
    void sendMessageToPlugin(const QString &msg) override;
    ~plugin_output()
    {
        delete plugin_output_ui; // 确保释放内存
    }

private:
    Ui::plugin_output *plugin_output_ui = nullptr; // UI指针成员
    QWidget *pluginWidget = nullptr;
    outputConfigWidget mOutputConfigWidget;
    void processJsonCommand(const QString &jsonStr); // 解析json命令并处理
    void initUi();
};

#endif // plugin_output_H